package com.example.tms.controller;

import com.example.tms.bean.*;
import com.example.tms.mapper.OilcardMapper;
import com.example.tms.mapper.OilfillMapper;
import com.example.tms.mapper.OilfillVMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 充油信息
 */
@RestController
public class OilfillController {

    private final OilfillMapper oilfillMapper;
    private final OilfillVMapper oilfillVMapper;

    @Autowired
    public OilfillController(OilfillMapper oilfillMapper, OilfillVMapper oilfillVMapper) {
        this.oilfillMapper = oilfillMapper;
        this.oilfillVMapper = oilfillVMapper;
    }

    //查询充油信息列表
    @RequestMapping(value = "oilfill", method = RequestMethod.GET)
    public ReturnInfo getOilfillInfoAll() {
        return ReturnInfo.info2(oilfillMapper.findAll());
    }

    //查询充油信息(油卡号)
    @RequestMapping(value = "oilfill/{ykh}", method = RequestMethod.GET)
    public ReturnInfo getOilfillView(@PathVariable String ykh) {
        return ReturnInfo.info2(oilfillVMapper.findByYkh(ykh));
    }

    //更新信息
//    @RequestMapping(value = "oilfill", method = RequestMethod.PUT)
//    public List<Map<String, Object>> updateOilfillinfo(@RequestBody OilfillInfo oilfillInfo) {
//        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//        Map<String, Object> map = new HashMap<String, Object>();
//       // OilcardMgmt oilcardMgmt = oilcardMapper.findByYkh(oilfillView.getYkh());
//
//        if (map.isEmpty()) {
//            oilfillMapper.saveAndFlush(oilfillInfo);
//        }
////        if (oilfillVMapper.findAll()!= null) {
////            String Ljsjcyje = oilfillVMapper.sumSjcyje(oilfillView.getYkh());
////            oilcardMgmt.setLjsjcyje(Ljsjcyje);
////        } else {
////            oilcardMgmt.setLjsjcyje("");
////        }
//        return list;
//    }

    }


